using System;
using System.Collections.Generic;
using Mbs.Modularity.AddIns;
using Mbs.ComponentModel.Container;

namespace Mbs.Elements
{
    [Serializable]
    public abstract class ElementBuilder : MarshalAndDisposableObject, IElementBuilder
    {
        public ICompositeDisposableObject Disposes { get; private set; }
        [Inject]
        public IAddInTree AddInTree { protected get; set; }

        protected ElementBuilder()
        {
            Disposes = new CompositeDisposableObject();
        }

        public abstract object Create(object caller, IAddInItem element);
        public virtual void InitInstance(object caller, IAddInItem element, List<object> subItems, object instance) { }

        protected override void Dispose(bool disposing)
        {
            Disposes.Dispose();
        }
    }
}
